/************************
 * Source Interests Panel
 */
AIR2.Source.Interests = function() {
    function filterStore(svdata) {
        var svStore = new Ext.data.JsonStore(AIR2.Source.SVDATA);
        return svStore;
    }
    
    return new AIR2.UI.Panel({
        colspan: 1,
        title: 'Interests',
        iconCls: 'air2-source-interests-icon',
        storeData: filterStore(AIR2.Source.SVDATA),
        url: AIR2.Source.BASEURL + '/src_vita',
        itemSelector: '.air2-source-interests',
        tpl: new Ext.XTemplate(
            '<div class="air2-source-interests">' +
            '<table class="air2-source">' +
              '<tpl for=".">' +
                '<tpl if="sv_type == \'I\'">' +
                  '<tr>' +
                    '<td class="txtright"><span>{[this.fvalue(values.sv_notes)]}</span></td>' +
                  '</tr>' +
                '</tpl>' +
              '</tpl>' +
            '<table>' +
            '</div>',
            {
                compiled: true, 
                disableFormats: true,
                fvalue: function(fvalue) {
                    var ret;
                    ( fvalue != null ) ? ret = fvalue : "";
                    return ret;
                }
            }            
        ),
        editModal: {
            allowAdd: AIR2.Source.SUMMDATA.authz.may_write,
            items: {
                xtype: 'air2liveeditor',
                url: AIR2.Source.BASEURL + '/src_vita',
                pageSize: 50,
                allowEdit: AIR2.Source.SUMMDATA.authz.may_write,
                allowDelete: AIR2.Source.SUMMDATA.authz.may_write,
                hideButtons: true,
                editForm: {
                    items: [{
                        xtype: 'textarea',
                        fieldLabel: 'Interest',
                        name: 'sv_notes'
                    }],
                },
                tpl: new Ext.XTemplate(
                    '<div class="air2-source-interests">' +
                      '<tpl if="sv_type == \'I\'">' +
                        '{values.sv_notes} ' +
                        '<button class="air2-rowedit"></button>' +
                        '<button class="air2-rowdelete"></button>' +
                      '</tpl>' +  
                    '</div>',
                    { compiled: true, disableFormats: true }
                )                
            }
        }        
    });
}
